Skip to content

context: direction and max_depth bound the walk - #2034

Open
Ayingxizhao wants to merge 2 commits into
AxiomCodeAI:devfrom
Ayingxizhao:feat/context-walk-bounds
Open

Ayingxizhao wants to merge 2 commits into
AxiomCodeAI:devfrom
Ayingxizhao:feat/context-walk-bounds

Conversation

@Ayingxizhao

Copy link
Copy Markdown
Contributor

Builds on #2033.

What changed

context's direction and max_depth now bound its two walks, and the answer says where the file walk stopped.
Left out, both walks keep today's bounds, so default answers are unchanged.

  • ax_walk.py (new): which way a walk follows a call edge, as one definition for the CLI and the MCP server.
    DIRECTIONS = {'callees': {FORWARD}, 'callers': {BACKWARD}, 'both': {FORWARD, BACKWARD}}. A direction is a set of
    ways, so a new one is one more entry rather than a new branch in each verb.
  • neighbourhood() (the file walk) takes direction and builds only the edges it follows; its fixed cap=3 becomes
    NEIGHBOURHOOD_DEPTH, overridden by --depth. Given a report, it records depth_reached and stop_reason
    (complete, or depth_limit when the cap left something unreached).
  • flow() takes --depth as its depth_cap (default FLOW_DEPTH, as before). The flow follows calls forward, so
    it is not told when the walk goes only to callers.
  • --json: omitted lists the files the budget cut, and stop_reason is then budget_limit.
  • The "within 3 hops" lines and the flow's "to depth 4" header print the depth actually used.
  • mcp/server.py checks direction against ax_walk.DIRECTIONS instead of its own list.
  • SKILL.md, AGENTS.md: what direction and max_depth mean.

Why the goldens moved, or why they did not

No golden moved. Nothing under test/*/expected changed: this touches the query side only, not the rules or the
parser.

Evidence

New case tests/cases/python/context-walk-direction-and-depth, a chain
checkout → charge_card → send_receipt → write_log, one function per file:

Asked from send_receipt Files listed
no bounds (control) payment, logger, checkout
direction callers payment, checkout
direction callees logger
direction callers, depth 1 payment

and for the flow from checkout: depth 1 stops at charge_card; direction callers tells no flow.
Against #2033's code, 5 of the case's 6 checks fail (the control passes), so the case tests this change.

Checklist

  • tests/run.py --lang python: 485 of 489 pass; the 4 failures (text-interpolated-phrase,
    text-when-the-graph-has-no-answer) fail the same way on dev
  • tests/front_door.py 21 of 21; tests/mcp.py, tests/mcp_docs.py pass; tests/surfaces.py fails only on
    README.md CLI section: names the flag --fresh, as on dev
  • No golden moved
  • Validated over the CLI and over MCP
  • Labels set

start_symbol and token_budget map to the existing --from and --page-budget;
direction and max_depth are checked but not yet used; expand_context is
refused as not implemented. With the new inputs left out, answers are unchanged.
The file walk follows only the edges a direction asks for, out to --depth;
the flow takes --depth as its cap and is not told for callers only. Which way
a direction follows an edge is defined once, in ax_walk.py, for the CLI and
the MCP server. With the inputs left out, both walks keep today's bounds.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant